package cn.edu.hunau.oop.day08;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
import java.util.function.Predicate;

/**
 * @author hb
 * @date 2025-08-13 11:28:22
 */
public class FilterRice {

    public static <R> List<R> map(List<Rice> datas, Function<Rice,R> fun){
        List<R> result = new ArrayList<>();
        for (Rice rice : datas) {
                  result.add(fun.apply(rice));
        }
        return result;
    }

    public static List<Rice> filer(List<Rice> datas, Predicate<Rice> prdicate){
        List<Rice> result = new ArrayList<>();
        for (Rice rice : datas) {
            if(prdicate.test(rice)){
                result.add(rice);
            }
        }
        return result;
    }
}
